<?php 
require_once (dirname(__FILE__).'/services.php');

function people_index_overview($matches) {
    global $mvc;
    
    $method = $_SERVER['REQUEST_METHOD'];
    
	if ($method == "GET") {
    	global $member_list;
    	global $alumnus_list;

		$member_list = service_people_get_peoplelist_by_catagory('member', 0, 12);
		$alumnus_list = service_people_get_peoplelist_by_catagory('alumnus', 0, 12);

    	$mvc->render(dirname(__FILE__)."/views/_people_index_overview_.php");
    } elseif ($method == "POST") {
    	
    }
}

function people_person_detail($matches) {
	global $mvc;
	
	$query = $matches['1'];
	$method = $_SERVER['REQUEST_METHOD'];
	
	if ($method == "GET") {
		if ($query == "member" || $query == "alumnus") {
			global $people_list;
			
			$people_list = service_people_get_peoplelist_by_catagory($query);
			$mvc->render(dirname(__FILE__)."/views/_people_catagory_overview_.php");
		} else {
			global $person;
			$person = service_people_get_person_by_fullname($query);
			$mvc->render(dirname(__FILE__)."/views/_people_details_.php");
		}
	} elseif ($method == "POST") {
		
	}
}

global $mvc;
$mvc = new MVC(Array(
	'{^/people/$}' => 'people_index_overview',
	'{^/people/(\w+)/}' => 'people_person_detail'
));
$mvc -> dispatch($GLOBALS['uri']);
?>